<?php

/**
* Controller:  "Events"
*
* This controller loads the "Events" page, which lists all community
* events in the database.  Events are gathered and sent to the view, where
* they are arranged and displayed in table form.
*
* Functions:  index
*
* @author     Brandon A Johnson
* @copyright  LIS4368-01: "Web Development with PHP," Spring 2010
* @version    1.0
* @date       April 24, 2010
*
*/

class Events extends Controller {

	/**
	* Events() - constructor
	*
	* allows this file to act as a valid CodeIgniter controller
	*/
	function Events()
	{
		parent::Controller();
	}
	
	/**
	* index() - default function
	*
	* displays all community events currently in the database
	*/
	function index()
	{
		// destroys the cookie session just in case someone clicks here from the secure section
		$this->load->library('session');
		$this->session->sess_destroy();

		// loads the "events" database interaction model
		$this->load->model('events_model');
		// extracts all event records currently in the table
		$all_events = $this->events_model->list_events();
		// prepares the data to be sent to the view
		$data = array();
		$data['results'] = $all_events;

		// loads the header and displays all events, each within its own table
		$this->load->view('header');
		$this->load->view('events', $data);
	}
}

/* End of file events.php */
/* Location: ./system/application/controllers/events.php */